package com.mdd.common.utils;

import com.github.binarywang.wxpay.service.WxPayService;
import com.mdd.common.enums.PayChannelEnum;
import com.mdd.common.exception.OperateException;
import org.apache.commons.lang3.StringUtils;

/**
 * @ClassName SnUtils
 * @Description
 * @Autore Slien.zuo
 * @Date 2022/10/10 15:58
 * @Version 1.0
 **/
public class WxPayServiceUtils {

    /**
     * @return java.lang.String
     * @Author slien
     * @Description 获取一个订单编号
     * @Date 14:23 2022/10/11
     * @Param []
     **/
    public static WxPayService wxPayService(String channel) {
        if (PayChannelEnum.MP_CHANNEL.getCode().equals(channel) || StringUtils.isEmpty(channel)) {
            return (WxPayService) SpringUtil.getBean("mpWxPayService");
        } else if (PayChannelEnum.OA_CHANNEL.getCode().equals(channel) || StringUtils.isEmpty(channel)) {
            return (WxPayService) SpringUtil.getBean("oaWxPayService");
        } else if (PayChannelEnum.H5_CHANNEL.getCode().equals(channel) || StringUtils.isEmpty(channel)){
            return (WxPayService) SpringUtil.getBean("h5WxPayService");
        } else {
            throw new OperateException("目前不支持此支付方式");
        }
    }

}
